package com.lsw.jgyf.ui.activity;

import android.content.Intent;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.lsw.dialog.PubDialogUtil;
import com.lsw.jgyf.R;
import com.lsw.jgyf.ui.base.activity.TitleBarActivity;
import com.lsw.util.AppManager;
import com.lsw.util.DialogUtil;

import butterknife.BindView;

/**
 * Created by lsw on 2018/7/8.
 */

public class ChangePassWordActivity extends TitleBarActivity<ChangePassWordPresenter> implements View.OnClickListener, ChangePassWordContract.View {
    @BindView(R.id.tv_true)
    TextView tv_true;
    PubDialogUtil dialogUtil;
    @BindView(R.id.et_oldpass)
    EditText et_oldpass;
    @BindView(R.id.et_pass)
    EditText et_pass;
    @BindView(R.id.et_password)
    EditText et_password;


    @Override
    protected void initInjector() {
        mActivityComponent.inject(this);
    }

    @Override
    protected void initEventAndData() {
        tv_true.setOnClickListener(this);
        dialogUtil = new PubDialogUtil(mContext);
    }

    @Override
    protected int setContentLayoutView() {
        return R.layout.activity_change_password;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_true:
                mPresenter.ChangePhone(et_oldpass.getText().toString().trim(), et_pass.getText().toString().trim(), et_password.getText().toString().trim());
                break;
        }
    }

    @Override
    public void ChangeSucceed() {
        dialogUtil.showDialogtitleText("修改密码成功", "点击确定可直接登录\n极果优分", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, MainActivity.class);
                startActivity(intent);
                AppManager.getAppManager().finishAllMainActivity(MainActivity.class);
            }
        }, false, "");
    }

    @Override
    protected void setActionBarDetail() {

    }

    @Override
    public void openlogin() {
        OpenLogin();
    }
}
